<?php
require("../config.php");
require_once($CONF['root.dir']."database.php");
$id_pelamar     = $_POST["id_pelamar"];
$nama 		 	= $_POST["nama"];
$tmp_lahir 		= $_POST["tmp_lahir"];
$tgl_lahir 		= $_POST["tgl_lahir"];
$hasil_test 	= $_POST["hasil_test"];
$DATA 		 	= $_POST["DATA"];
$ACTION 		= $_POST["ACTION"];

if(strtoupper($ACTION)=="SAVE"){
	$SQL="INSERT INTO tbltes 
			(id_pelamar, 
			nama, 
			tmp_lahir, 
			tgl_lahir, 
			hasil_test
			)
			VALUES
			('".$id_pelamar."', 
			'".$nama."', 
			'".$tmp_lahir."', 
			'".frmtanggal($tgl_lahir)."', 
			'".$hasil_test."'
			)";
	$conn->connect();
	$exec=$conn->execute($SQL);
	$conn->disconnect();
	if($exec){echo "1|Data berhasil diproses.".$SQL;}else{echo "0|Data gagal diproses.";}
}else if(strtoupper($ACTION)=="UPDATE"){
	$conn->connect();
	$SQL = "UPDATE tbltes 
			SET
			id_pelamar = '".$id_pelamar."' , 
			nama = '".$nama."' , 
			tmp_lahir = '".$tmp_lahir."' , 
			tgl_lahir = '".frmtanggal($tgl_lahir)."' , 
			hasil_test = '".$hasil_test."',
			status='1',
			tgl_periksa=sysdate()
			WHERE
			id_test = '".$DATA."' ;
		";
	$exec=$conn->execute($SQL);
	$conn->disconnect();
	if($exec){echo "1|Data berhasil diproses.";}else{echo "0|Data gagal diproses.".$SQL;}
}

?>